// 引入二次封装的axios
import request from '../utils/request'
// 引入soute

// 封装方法获取用户已选频道
const getUserChannelListAPI = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/channels'
  })
}

// 封装方法获取文章列表接口
const articlesListAPI = ({ channelId, timestamp = Date.now() + '' }) => {
  return request({
    method: 'GET',
    url: '/v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp
    }
  })
}
// 封装文章不感兴趣接口
const articleDisLikeAPI = (id) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    data: {
      target: id
    }

  })
}

// 封装文章举报接口
const articleReportsAPI = ({ id, type, remark }) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/reports',
    data: {
      target: id,
      type: type + '',
      remark: type === '0' ? remark : remark || null
    }
  })
}

// 封装一个方法发送获取所有频道
const getAllChannelListAPI = () => {
  return request({
    method: 'GET',
    url: '/v1_0/channels'
  })
}
// 封装方法修改(更新)用户选择的频道
const updateUserchannelListAPI = (channels) => {
  return request({
    method: 'PUT',
    url: '/v1_0/user/channels',
    data: {
      channels
    }
  })
}
// 导出
export {
  getUserChannelListAPI,
  articlesListAPI,
  articleDisLikeAPI,
  articleReportsAPI,
  getAllChannelListAPI,
  updateUserchannelListAPI
}
